//
//  SXLoadingView.m
//  ShiXun
//
//  Created by lanou on 15/10/24.
//  Copyright © 2015年 张琪. All rights reserved.
//

#import "SXLoadingView.h"

@implementation SXLoadingView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width / 2 - 110, 5, 40, 40)];
        NSMutableArray *array = [NSMutableArray array];
        for (int i = 1; i < 3; i++) {
            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"SX-shuaxin%d.png", i]];
            [array addObject:image];
        }
        imageView.animationImages = array;
        [imageView setAnimationDuration:0.5];
        [imageView startAnimating];
        [self addSubview:imageView];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width / 2 - 40, 0, self.frame.size.width / 2, 50)];
        label.numberOfLines = 2;
        
        NSDate *senddate=[NSDate date];
        NSDateFormatter  *dateformatter=[[NSDateFormatter alloc] init];
        [dateformatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
        NSString *locationString=[dateformatter stringFromDate:senddate];
        
        label.text = [NSString stringWithFormat:@"时讯数据加载中\n%@", locationString];
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = [UIColor redColor];
        
        [self addSubview:label];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
